/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package treccontextsug;

import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;

/**
 *
 * @author manzato
 */
public class ExamplesSet extends Parser {
    private ArrayList<Example> examples;
    
    private static final String[] keywords = {"museum", "prision", "gift shop", "park", "bar", "pub", 
        "food", "market", "restaurant", "cafe", "shopping", "mall", "establishment", "theater", "theatre",
        "hall", "library", "factory", "spa", "night club", "show", "zoo", "memorial"};
    
    public static final ArrayList<String> baseKeywords = new ArrayList(Arrays.asList(keywords));
    
    public ExamplesSet(String examplesFile) {
        super(examplesFile);
        this.examples = new ArrayList();
    }

    @Override
    public void readJSON() throws IOException, ParseException {
        jsonObject = (JSONObject) parser.parse(new FileReader(filename));
        Set<String> set = jsonObject.keySet();
        
        for(String s : set) {
            JSONObject j = (JSONObject)jsonObject.get(s);
            String url = (String)j.get("url");
            String description = (String)j.get("description");
            String title = (String)j.get("title");
            String[] keywords = ((String)j.get("keywords")).split(",");
            
            Example e = new Example(s, url, description, title, keywords);
            examples.add(e);
        }
    }
    
    public ArrayList<Example> getAllExamples() {
        return examples;
    }
}
